{{- if default false $.Site.Params.sidebar.archives }}
{{- $basePath := strings.TrimSuffix "/" (default "/archives" .Site.Params.archive.basePath) }}
{{- $basePath = printf "/%s/" (strings.TrimPrefix "/" $basePath)  }}
{{- $archivePage := $.GetPage $basePath }}
{{- $collapsed := default false .Site.Params.sidebar.collapsed }}
<div class="accordion archives">
  <section class="row card component">
      <div class="card-header">
        <h2 class="card-title my-2 fs-4 text-surface d-none d-lg-block">
            {{- with $archivePage }}
            <a href="{{ .RelPermalink }}">{{ i18n "archives" }}</a>
            {{- else }}
            {{ i18n "archives" }}
            {{- end }}
        </h2>
        <a
          class="accordion-button d-lg-none mb-1 shadow-none p-0 bg-transparent{{ if $collapsed }} collapsed{{ end }}"
          role="button" data-bs-toggle="collapse" href="#archives" aria-expanded="{{ if $collapsed }}false{{ else }}true{{ end }}" aria-controls="archives">
            {{ i18n "archives" }}
        </a>
      </div>
      <div class="card-body collapse accordion-collapse accordion-body d-lg-block{{ if not $collapsed }} show{{ end }}" id="archives">
        {{- partial "sidebar/archive-items" . }}
      </div>
  </section>
</div>
{{- end }}
